package com.web.security;

import com.web.security.filter.IgnoreUrlList;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
import org.springframework.security.web.util.matcher.RequestMatcher;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author liuxuhuang
 * @date 2023年04月02日 11:22
 */
@Configuration
public class IgnoreMatcherConfig {
    @Resource
    private IgnoreUrlList ignoreUrlList;

    @Bean
    public RequestMatcher[] requestMatchers() {
        List<AntPathRequestMatcher> list = ignoreUrlList.getUrl().stream().map(AntPathRequestMatcher::new).collect(Collectors.toList());
        return list.toArray(new RequestMatcher[0]);
    }
}
